/*

    tools23d - tools for converting images to 3D formats.
    Copyright (C) 2014  Dave Gorst

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef GLOB_H
#define	GLOB_H

#ifdef	__cplusplus
extern "C" {
#endif

/**
Entry in the file list containing file details and pointers to next and previous entries in the linked-list.

*/

typedef struct file_entry
{
	char * filepath;	/**<String containing the absolute filename and path. */
	time_t change_time;	/**<Last time file was changed - in practise this is usually the creation date. */
	struct file_entry * previous;	/**<Pointer to the previous file entry structure. */
	struct file_entry * next;	/**<Pointer to the next file entry structure. */
} file_entry;

typedef struct
{
	unsigned int number_of_files;	/**<The number of files currently contained in the list. */

	file_entry ** files_list;	/**<Pointer to a list of pointers to ::file_entry structures. */

	file_entry * start;	/**<Pointer to the first ::file_entry structure in the list. */
	file_entry * end;	/**<Pointer to the last ::file_entry structure in the list. */
} globule;

typedef file_entry * pfilenames;

unsigned int T3D_InitialiseGlob (void);
void T3D_DestroyGlob (unsigned int);
void T3D_ShutdownGlob (void);
file_entry * T3D_RetrieveGlobEntry (unsigned int, unsigned int);
unsigned int T3D_AppendEntry (unsigned int, char *, time_t);
unsigned int T3D_PopulateGlob (unsigned int, char *);
unsigned int T3D_GetNumberOfEntries (unsigned int);
BOOL T3D_SortGlobule (unsigned int, SortType);

#ifndef NULL
	#define NULL 0L
#endif

#ifndef MAX_PATH
	#ifdef PATH_MAX
		#define MAX_PATH PATH_MAX
	#else
		#define MAX_PATH 32768
	#endif
#endif

#define UNABLE_TO_INITIALISE_GLOBULE    ((unsigned int) -1)

#ifdef	__cplusplus
}
#endif

#endif	/* GLOB_H */

